NXT_SendKeepAlive
Sends a KeepAlive packet. Optional: requests sleep time limit.
Contents
Syntax
[status SleepTimeLimit] = NXT_SendKeepAlive(ReplyMode)
[status SleepTimeLimit] = NXT_SendKeepAlive(ReplyMode, handle)
Description
[status SleepTimeLimit] = NXT_SendKeepAlive(ReplyMode) sends a KeepAlive packet to the NXT Brick to get the current sleep time limit of the Brick in milliseconds. By the ReplyMode one can request an acknowledgement for the packet transmission. The two strings 'reply' and 'dontreply' are valid. status indicates if an error occures by the packet transmission. Function checkStatusBytes is interpreting this information per default. The value SleepTimeLimit contains the time in milliseconds after the NXT brick will turn off automatically. The variable will only be set if ReplyMode is 'reply'. The sleep time limit setting can only be modified using the on-screen-menu on the brick itself.
Using 'dontreply' will just send a keep-alive packet. This means, the NXT internal counter when to shut down automatically (this is a setting that can only be accessed directly on the NXT) will be reset. This counter is not an inactivity counter: Bluetooth traffic will NOT stop the NXT from turning off. E.g. if the sleep limit is set to 10 minutes, the only way to keep the NXT Brick from turning off is to send a keep-alive packet within this time.
If you use replymode 'reply', SleepTimeLimit tells you the current setting on the brick, in milliseconds. 0 means sleep timer is disabled. -1 is an invalid answer: You obviously didn't use 'reply' and still tried to get an answer.
[status SleepTimeLimit] = NXT_SendKeepAlive(ReplyMode, handle) uses the given NXT connection handle. This should be a struct containing a serial handle on a PC system and a file handle on a Linux system.
If no NXT handle is specified the default one (COM_GetDefaultNXT) is used.
For more details see the official LEGO Mindstorms communication protocol.
Note:
This function is also used if you call COM_OpenNXT() with the optional 'check' parameter. Then a keep-alive packet is send and the answer will be received to check for a correctly working bidirectional bluetooth connection.
Examples
[status SleepTimeLimit] = NXT_SendKeepAlive('reply');
NXT_SendKeepAlive('dontreply');
handle = COM_OpenNXT('bluetooth.ini','check'); [status SleepTimeLimit] = NXT_SendKeepAlive('reply', handle);
See also
COM_OpenNXT, NXT_GetBatteryLevel
Signature
- Author: Linus Atorf (see AUTHORS)
- Date: 2007/10/15
- Copyright: 2007-2008, RWTH Aachen University